#pragma once
#include "afxwin.h"
#include "WeaponDefs.h"
#include "Functions.h"
#include "ProgressBarDialog.h"

class CWeapTTX;
#pragma warning(disable: 4996)//'wcstombs' was declared deprecated, 'swprintf' was declared deprecated, 1>        Message: 'swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.' ...

#define WEAPON_LOAD   "\\weapon.ini"
#define WEAPON_SAVE   "\\weapon.ini"
class CWeaponDlg : public CDialog
{
	DECLARE_DYNAMIC(CWeaponDlg)

public:
	CWeaponDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CWeaponDlg();

// Dialog Data
	enum { IDD = IDD_WEAPONS };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

private:
  bool m_bSaved;
public:
  bool IsSaved() const;
  //CToolTipCtrl m_tooltip;
  COXToolTipCtrl m_tooltip;

	WEAPONTYPE Weapon[ MAX_WEAPON_TYPES ];
	WEAPONTYPE *pCurWeapon;
	WEAPONTYPE NW;
	MAGTYPE Magazine[MAX_MAGAZINES];
	CaliberStruct gCalibers[MAX_CALIBERS];	
	AMMOTYPE gAmmoTypes[MAX_AMMOTYPES];
	WEAPONCLASS gWeaponClass[MAX_WEAPON_CLASSES];
	CaliberBinds ftbBinds[NUM_OF_CALS];
	void AddBind(UINT8 iCal, UINT8 iMagSize, UINT8 iFT);
	void FillBind(UINT8 FT);
	void FillMags(UINT8 FT, UINT8 iFeedType);
	void FillCalibers();
	void FillWClasses();
	UINT8 GetWeaponClassIdByAlias(TCHAR * tsAlias);
	UINT8 GetCaliberIdByAlias(TCHAR * tsAlias);
	UINT8 GetAmmoTypeIdByAlias(TCHAR * tsAlias);
	
	TCHAR* MakeEdSTR(TCHAR *STR, TCHAR *ts);
	int m_Var;
	int LastWeapon;
	int Load( CProgressBarDialog *pProgressDialog );
	int Start();
	int GetWeaponIniSettings( CProgressBarDialog *pProgressDialog );
	void ChangeSel();
	int fEdit(int nID, int nNumber);
	void OnOK();
	void OnCancel();
	int Save(void);
	CListBox m_ListBox;
	CComboBox m_cbWeapClass;
	CComboBox m_cbCalibre;
	afx_msg void OnCbnSelchangeComboWeaponClass();
	afx_msg void OnCbnSelchangeComboCaliber();
	afx_msg void OnEnChangeEditWeapType();
	afx_msg void OnEnChangeEditReadyTime();
	afx_msg void OnEnChangeEditShotsPer4Turns();
	afx_msg void OnEnChangeEditBulletSpeed();
	afx_msg void OnEnChangeEditDeadliness();
	afx_msg void OnEnChangeEditMagSize();
	afx_msg void OnEnChangeEditRange();
	afx_msg void OnEnChangeEditAttackVolume();
	afx_msg void OnEnChangeEditHitVolume();
	afx_msg void OnEnChangeEditReloadAPs();
	afx_msg void OnEnChangeEditImpact();
	afx_msg void OnEnChangeEditReloadDelay();
	afx_msg void OnEnChangeEditShotSpread();
	afx_msg void OnEnChangeEditBulletsMode0();
  afx_msg void OnEnChangeEditBulletsMode1();
  afx_msg void OnEnChangeEditBulletsMode2();
	afx_msg void OnEnChangeEditROFMode0();
  afx_msg void OnEnChangeEditROFMode1();
  afx_msg void OnEnChangeEditROFMode2();
	afx_msg void OnEnChangeEditPenaltyMode0();
	afx_msg void OnEnChangeEditPenaltyMode1();
	afx_msg void OnEnChangeEditPenaltyMode2();
	afx_msg void OnLbnSelchangeListWeapons();
	afx_msg void OnEnChangeEditSound();
	afx_msg void OnEnChangeEditReloadSound();
	afx_msg void OnEnChangeEditBurstSound();
	afx_msg void OnEnChangeEditLockNLoadSound();
	afx_msg void OnBnClickedCheckFixedMagazine();
	afx_msg void OnBnClickedCheckSelfloading();
	afx_msg void OnCbnSelchangeComboMagSize();
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
  CButton m_chbFixMag;
	CButton m_chbSelfL;
	CComboBox m_cbFeedType;
  CComboBox m_cbMagSize;
	CEdit m_ebMagSize;
	//Pointers to other classes
	CWeapTTX *pWeapTTX;
	CItemsDlg *pItemsDlg;

	void SetClassPointers(ClassPointers *p);
	//-------------------------
	WSPointers wspPointers;
	afx_msg void OnCbnSelchangeComboFeedType();
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	void ActualizeData();

	BOOL PreTranslateMessage(MSG* pMsg) 
	{
		if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
			m_tooltip.RelayEvent(pMsg);

		return CDialog::PreTranslateMessage(pMsg);
	}
};
